package class_sources;

import java.util.ArrayList;
import java.util.HashMap;

import org.ksoap2.serialization.PropertyInfo;

public class CommandProc {
	WSandJson wsHelper=new WSandJson();
	public Boolean SetCommand(int is_command,String command,String command_message,String session)
	{
		PropertyInfo[] p=new PropertyInfo[4];
		p[0]=new PropertyInfo();
		p[1]=new PropertyInfo();
		p[2]=new PropertyInfo();
		p[3]=new PropertyInfo();
		p[1].setName("command");
		p[1].setValue(command);
		p[1].setType(String.class);
		p[2].setName("command_message");
		p[2].setValue(command_message);
		p[2].setType(String.class);
		p[0].setName("is_command");
		p[0].setValue(Integer.toString(is_command));
		p[0].setType(String.class);
		p[3].setName("session");
		p[3].setValue(session);
		p[3].setType(String.class);
		String result=wsHelper.CallWSFunction("urn:ProductsService", "http://www.codediary.net/service/roadship_service.php", "setCommand", "urn:User#setCommand",p);
		ArrayList<HashMap<String, String>> arrayList=new ArrayList<HashMap<String,String>>();
		arrayList=wsHelper.JsonToArrayList(result);
		if(arrayList.get(0).get("Result").contains("false"))
			return false;
		else
			return true;
	}
	
	public ArrayList<HashMap<String, String>> GetCommand(String session)
	{
		PropertyInfo[] p=new PropertyInfo[1];
		p[0]=new PropertyInfo();
		p[0].setType(String.class);
		p[0].setName("session");
		p[0].setValue(session);
		String result=wsHelper.CallWSFunction("urn:ProductsService", "http://www.codediary.net/service/roadship_service.php", "getCommand", "urn:User#getCommand",p);
		ArrayList<HashMap<String, String>> arrayList=new ArrayList<HashMap<String,String>>();
		arrayList=wsHelper.JsonToArrayList(result);
		return arrayList;
	}

}
